package red.internal.client.policy;

/**
 * @author Jin Zheng
 * @since 1.0 2020-03-27
 */
public interface RetryPolicy
{
	/**
	 * Called when an operation has failed for some reason. This method should return
	 * true to make another attempt.
	 *
	 * @param retryCount the number of times retried so far (0 the first time)
	 * @return true/false
	 */
	boolean allowRetry(int retryCount);

	/**
	 * get sleep time in ms of current retry count.
	 *
	 * @param retryCount current retry count
	 * @return the time to sleep
	 */
	int getSleepTimeMs(int retryCount);
}
